package com.jdrx.sw.sewage.api.web;

import com.jdrx.platform.commons.rest.beans.vo.ResponseVO;
import com.jdrx.platform.commons.rest.factory.ResponseFactory2;
import com.jdrx.sw.sewage.common.constant.Constant;
import com.jdrx.sw.sewage.common.enums.EDigitalTwinFileType;
import com.jdrx.sw.sewage.service.DigitalTwinServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/api/digitaltwin")
@Api(value = "数字孪生")
public class DigitalTwinApi {

    @Autowired
    private DigitalTwinServiceImpl digitalTwinServiceImpl;

    @ApiOperation(value = "获取viewToken")
    @RequestMapping(value = "viewToken", method = RequestMethod.GET)
    public ResponseVO<String> viewToken(@RequestHeader(Constant.TENANT_ID) String tenantId,
                                        @RequestParam("fileId") Long fileId,
                                        @RequestParam("fileType") EDigitalTwinFileType fileType) throws Exception {
        return ResponseFactory2.ok(digitalTwinServiceImpl.getViewToken(fileId, fileType, tenantId));
    }

    @ApiOperation(value = "为文件创建bake数据包")
    @RequestMapping(value = "addBake", method = RequestMethod.GET)
    public ResponseVO<String> addBake(@RequestHeader(Constant.TENANT_ID) String tenantId,
                                      @RequestParam("fileId") Long fileId) throws Exception {
        digitalTwinServiceImpl.addBake(fileId);
        return ResponseFactory2.ok();
    }
}
